package game.gui.panelconversation;

import game.model.conversation.Dialogue;
import game.model.conversation.Monologue;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Gab'z
 */
public class PanelConversation extends JPanel {

    private static PanelConversation panelConversation = null;
    private PanelConvDialogue panelDialogue;
    private PanelConvMonologue panelMonologue;
    private PanelConvInfo panelInfo;

    private PanelConversation() {
        this.setSize(680, 190);
        this.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        this.add(new JLabel());
        panelDialogue = PanelConvDialogue.getPanelConvDialogue();
        panelMonologue = PanelConvMonologue.getPanelConvMonologue();
        panelInfo = PanelConvInfo.getPanelConvInfo();
    }

    public static PanelConversation getPanelConversation() {
        if (panelConversation == null) {
            panelConversation = new PanelConversation();
        }
        return panelConversation;
    }

    public void resetPanelConversation() {
        System.out.println("resetPanelConversation");
        this.removeAll();
        panelDialogue.removeAll();
        panelMonologue.removeAll();
        panelInfo.removeAll();
    }

    public void afficherMonologue(Monologue monologue) {
        resetPanelConversation();
        System.out.println("afficherMonologue");
        panelMonologue.setMonologue(monologue, monologue.getTypeInterlocuteur());
        this.add(panelMonologue);
    }

    public void afficherDialogue(Dialogue dialogue) {
        resetPanelConversation();
        System.out.println("afficherDialogue");
        panelDialogue.setDialogue(dialogue, dialogue.getTypeInterlocuteur());
        this.add(panelDialogue);
    }

    public void afficherDescription(String description) {
        System.out.println("afficherDescription");
        if (description != null) {
            afficherInfo(description);
        }
    }

    public void afficherInfo(String info) {
        resetPanelConversation();
        System.out.println("afficherInfo");
        panelInfo.setInfo(info);
        this.add(panelInfo);
    }
}
